package com.netintech.common.utils.hk;

import com.netintech.common.utils.JsonUtil;
import com.netintech.common.utils.hk.bean.PageData;
import com.netintech.common.utils.hk.bean.card.CareData;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Component;

import java.util.List;

@Component("eventCreate")
public class EventCreate {
	
    // private HkEventDao hkEventDao;
	
	// private static final String json = "{\"code\":\"0\",\"msg\":\"success\",\"data\":{\"total\":1,\"totalPage\":1,\"pageNo\":1,\"pageSize\":100,\"list\":[{\"eventId\":\"207dd3b1-37a7-4d6c-8e4d-c8bfd343051b\",\"eventName\":\"acs.acs.eventType.successCard\",\"eventTime\":\"2019-11-16T15:44:33+08:00\",\"personId\":\"216e2ba145824269a1cbb423cdc85cb1\",\"cardNo\":\"3891192334\",\"personName\":\"sdk人员1zzzcb\",\"orgIndexCode\":\"root000000\",\"orgName\":\"默认组织\",\"doorName\":\"10.40.239.69new_test2_门_1\",\"doorIndexCode\":\"f0b50050d3434f15b4e34f885d5dacfe\",\"doorRegionIndexCode\":\"fd2df06b-1afb-4c9b-b058-5740c2c00076\",\"picUri\":\"no-pcnvr\",\"svrIndexCode\":\"/pic?=d62i7f6e*6a7i125-c838b9--a8c67dea96e65icb1*=sd*=5dpi*=1dpi*m2i1t=4ed35444bb4s=-39\",\"eventType\":198914,\"inAndOutType\":1,\"readerDevIndexCode\":\"378e563bf3e84d5ba6ef5742bbaa8933\",\"readerDevName\":\"读卡器_1\",\"devIndexCode\":\"dcff422aad9c4d60a47b8b2fe2757b71\",\"devName\":\"10.40.239.69new_test2\",\"identityCardUri\":\"/pic?=d62i7f6e*6a7i125-c838b9--a8c67dea96e65icb1*=sd*=5dpi*=1dpi*m2i1t=4ed35444bb4s=-39z422d3\",\"receiveTime\":\"2019-11-16T15:45:13.525+08:00\",\"jobNo\":\"23333\",\"studentId\":\"201900001\",\"certNo\":\"320826199012110005\"}]}}";
	
	/**
     * 操作方法
	 * @throws AabException 
     */
    @SuppressWarnings("unused")
	public void process(String json) throws Exception {
    	CareData data = JsonUtil.fromJson(json, CareData.class);
    	List<HkEvent> list = ((PageData) data.getData()).getList();
    	for (HkEvent record : list) {
			try {
				// hkEventDao.insert(record);
			} catch (Exception e) {
				e.printStackTrace();
				if (e instanceof DuplicateKeyException) {
					
				} else {
					// throw new AabException(ExceptionCode.HK接口查询出入记录失败);
				}
			}
    	}
    }

}
